#pragma once
#include "GameObject.h"
#include "PhysicObject.h"
#include "FatPointer.h"
#include <list>
#include <string>
#include "Allegro.h"
//#include "Box2d.h"

//#define _HAS_ITERATOR_DEBUGGING false

class CollisionData
{
public:

	CollisionData(GameObject **a, GameObject **b, FatBase<void> *f, unsigned int t);
	~CollisionData();

	GameObject ** objectA;
	GameObject ** objectB;
	FatBase<void> * function;
	unsigned int type; // 1 - point, 2 - bouding box, 3 - sensor
};

class CollisionManager
{
	std::list <CollisionData*> data;

	inline bool BBCollision(GameObject *a, GameObject *b);
	inline bool pointCollision(GameObject *a, GameObject *b);
	bool sensorCollision(GameObject *a, GameObject *b); // object b is sensor
	
public:
	CollisionManager(void);
	~CollisionManager(void);

	void clearAll();
	void update();

	void setDetection(GameObject *& a, GameObject *& b, FatBase<void> *function, unsigned int type);
	void removeDetection(GameObject *& a, FatBase<void> *function = NULL, unsigned int type = 0); //removes detection for object a with given callback and type, or all with deault params
	void removeDetection(GameObject *& a, GameObject *& b, FatBase<void> *function = NULL, unsigned int type = 0); //removes detection for object a and b with given callback and type, or all with deault params 
};